package com.fourth.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fourth.dao.GoodsDao;
import com.fourth.service.GoodsService;
import com.fourth.vo.GoodVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljx.entity.BusinessInfo;
import com.ljx.entity.Goods;
import com.ljx.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xiaoZhu
 * @version 1.0
 * @date 2023/2/28 14:28
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements GoodsService {
    @Autowired
    private GoodsDao goodsDao;

    @Override
    public Result selectByPage(Integer currentPage, Integer pageSize, GoodVo goodVo) {

        PageHelper.startPage(currentPage,pageSize);
        if(goodVo.getGoodsname() != null || goodVo.getBusinessid() != null  || goodVo.getStatus()!= null || goodVo.getSortid()!=null){
            List<Goods> list=goodsDao.selectByPage(goodVo);
            PageInfo<Goods> info = new PageInfo<>(list);
            return new Result(200,"查询成功",info);
        }
        List<Goods> list=goodsDao.selectByPage2();
        PageInfo<Goods> info = new PageInfo<>(list);
        return new Result(200,"查询成功",info);

    }


}
